2 #include "ScreenNames.h"
3 #include "RescourceKeys.h"
6 //create the animations, load the text and then play the music
8 Menu::Menu(int* scrs
, FileIO
* filePntr
, ResourceMaster
* resourcePointer
)
10 hoverLevelSel
= false;
11 hoversettings
= false;
12 hovermusicRoom
= false;
15 rsc
= resourcePointer
;
17 renderer
= rsc
->rendPtr
;
20 outlineAnimation
= new Animation(rsc
->gameAnimations
.at(WhiteBlueBG
));
22 font
= new Fonts(0, rsc
);
24 int textSizeX
= font
->prcnt(0.20, 'x');
25 int textSizeY
= font
->prcnt(0.15, 'y');
26 int textAlignX
= font
->prcnt(0.75, 'x');
28 font
->loadFont(SDL_Color
{ 100,100,100,00 }, rsc
->gameText
.at(LevelSelectText
), 2);
29 textLevelSelect
= font
->getTexture();
30 rectLevelSelect
= {textAlignX
, font
->prcnt(0.05, 'y'), textSizeX
, textSizeY
};
32 font
->loadFont(SDL_Color
{ 100,100,100,00 }, rsc
->gameText
.at(SettingsText
), 2);
33 textSettings
= font
->getTexture();
34 rectSettings
= { textAlignX
, font
->prcnt(0.25, 'y'), textSizeX
, textSizeY
};
36 font
->loadFont(SDL_Color
{ 100,100,100,00 }, rsc
->gameText
.at(MusicRoomText
), 2);
37 textMusicRoom
= font
->getTexture();
38 rectMusicRoom
= { textAlignX
, font
->prcnt(0.45, 'y'), textSizeX
, textSizeY
};
40 font
->loadFont(SDL_Color
{ 100,100,100,00 }, rsc
->gameText
.at(QuitText
), 2);
41 textQuit
= font
->getTexture();
42 rectQuit
= { textAlignX
, font
->prcnt(0.65, 'y'), textSizeX
, textSizeY
};
55 delete outlineAnimation
;
59 void Menu::destroyFonts() {
60 SDL_DestroyTexture(textLevelSelect
);
61 SDL_DestroyTexture(textSettings
);
62 SDL_DestroyTexture(textMusicRoom
);
63 SDL_DestroyTexture(textQuit
);
68 hoverLevelSel
= false;
69 hoversettings
= false;
70 hovermusicRoom
= false;
73 if (x
> rectQuit
.x
&& y
> rectQuit
.y
) {
77 else if (x
> rectMusicRoom
.x
&& y
> rectMusicRoom
.y
) {
79 hovermusicRoom
= true;
81 else if (x
> rectSettings
.x
&& y
> rectSettings
.y
) {
86 else if (x
> rectLevelSelect
.x
&& y
> rectLevelSelect
.y
) {
91 ////cout << "notOvr\n";
92 hoverLevelSel
= false;
93 hoversettings
= false;
94 hovermusicRoom
= false;
98 if (mouseClicked
&& hoverLevelSel
) {
101 *screen
= LevelSelectScreen
;
103 else if (mouseClicked
&& hoversettings
) {
104 //cout << "Fired2\n";
106 *screen
= SettingsScreen
;
108 else if (mouseClicked
&& hovermusicRoom
) {
110 *screen
= MusicRoomScreen
;
112 else if (mouseClicked
&& hoverQuit
) {
121 hoverAddress
= &hoverLevelSel
;
123 else if (hoversettings
) {
124 hoverAddress
= &hoversettings
;
126 else if (hovermusicRoom
) {
127 hoverAddress
= &hovermusicRoom
;
129 else if (hoverQuit
) {
130 hoverAddress
= &hoverQuit
;
133 if (mouseClicked
&& (hoverLevelSel
|| hoversettings
|| hovermusicRoom
|| hoverQuit
)) {
134 rsc
->sptr
->playSFX(0);
137 if (!playedOnce
&& (hoverLevelSel
|| hoversettings
|| hovermusicRoom
|| hoverQuit
) || hoverAddress
!= hoverAddressOld
) {
138 rsc
->sptr
->playSFX(1);
141 else if(playedOnce
&& (hoverLevelSel
|| hoversettings
|| hovermusicRoom
|| hoverQuit
)){
149 hoverAddressOld
= &hoverLevelSel
;
151 else if (hoversettings
) {
152 hoverAddressOld
= &hoversettings
;
154 else if (hovermusicRoom
) {
155 hoverAddressOld
= &hovermusicRoom
;
157 else if (hoverQuit
) {
158 hoverAddressOld
= &hoverQuit
;
165 SDL_RenderClear(renderer
);
167 SDL_RenderCopy(renderer
, rsc
->gameBG
.at(T1BG
), NULL
, NULL
);
169 // SDL_Rect a = { 200,0,1000,1000 };
170 //SDL_RenderCopy(renderer, rsc->gameAnimations.at(1).at(2), NULL, &a);
173 SDL_RenderCopy(renderer
, outlineAnimation
->itterateAnimation(60), NULL
, &rectLevelSelect
);
175 else if (hoversettings
) {
176 SDL_RenderCopy(renderer
, outlineAnimation
->itterateAnimation(60), NULL
, &rectSettings
);
178 else if (hovermusicRoom
) {
179 SDL_RenderCopy(renderer
, outlineAnimation
->itterateAnimation(60), NULL
, &rectMusicRoom
);
181 else if (hoverQuit
) {
182 SDL_RenderCopy(renderer
, outlineAnimation
->itterateAnimation(60), NULL
, &rectQuit
);
185 SDL_RenderCopy(renderer
, textLevelSelect
, NULL
, &rectLevelSelect
);
186 SDL_RenderCopy(renderer
, textSettings
, NULL
, &rectSettings
);
187 SDL_RenderCopy(renderer
, textMusicRoom
, NULL
, &rectMusicRoom
);
188 SDL_RenderCopy(renderer
, textQuit
, NULL
, &rectQuit
);
191 SDL_RenderPresent(renderer
);